﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace Sita.Data.Core
{
    public static class IQueryableExtensions
    {
        public static IQueryable<T> Include<T>(this IQueryable<T> queryable, string path)
            where T : class
        {
            ObjectQuery<T> SourceQuery;

            SourceQuery = queryable as ObjectQuery<T>;

            foreach (string CurrentPath in path.Split(';'))
            {
                SourceQuery = SourceQuery.Include(CurrentPath);
            }

            return SourceQuery;
        }
    }
}
